<?php
/**
 * Created by PhpStorm.
 * User: sunshubo
 * Date: 2017/9/15
 * Time: 15:51
 */
?>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf8"/>
    <meta name="viewport"
          content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0"/>
    <link rel="stylesheet" type="text/css" href="/static/css/base.css?t=1505204250563"/>
    <link rel="stylesheet" type="text/css" href="/static/css/dpl.css?t=1505204250563"/>
    <link rel="stylesheet" type="text/css" href="https://wx-static.drip.im/css/shop/form/preview.css?t=1505204250563"/>
    <link rel="stylesheet" type="text/css" href="https://wx-static.drip.im/css/shop/form/activity.css?t=1505204250563"/>
    <link rel="stylesheet" type="text/css"
          href="https://wx-static.drip.im/css/fonts/form/iconfont.css?t=1505204250563"/>
    <!--    <meta http-equiv="Content-Security-Policy"-->
    <!--          content="script-src 'self' 'nonce-99b4ecf93d7b2b23' 'unsafe-inline' 'unsafe-eval' https: *.qq.com api.map.baidu.com wx-static.drip.im eco-api.meiqia.com wxs-b.drip.im hm.baidu.com;object-src *.qq.com *.youku.com;frame-src *.qq.com *.youku.com weixinping: weixin:">-->
    <!--<script src='js/lrz.all.bundle.js?t=1505204250563'></script>-->
    <!--<script src="js/sea.js?t=1505204250563"></script>-->
    <!--<script src="https://wx-static.drip.im/js/dist/shop/form/validate.js?92324,860188516"></script>-->
    <!--<script src="https://wx-static.drip.im/js/core/jquery-2.1.1.min.js?18934"></script>-->
    <script src="/static/js/public.js"></script>
    <script src="/static/js/jquery.js"></script>
    <script src="//cdn.bootcss.com/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
    <script src="//cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.js"></script>
    <script src="/static/js/qrcode.js"></script>
    <title> 文思学堂 - 学生信息录入</title>
</head>
<body>
<div class="screen">
    <div id="form" class='ui-form style_9'>
        <div class="ui-title"> 文思学堂 - 老师信息录入</div>
        <div class="ui-content form-fields">
            <div class="form-desc">
                <p>录入学生基本数据，请按要求填写。</p>
            </div>
            <label>
                <input id="marry" type="hidden" name="marry" value="0">
                <input id="sex" type="hidden" name="sex" value="0">
            </label>
            <div class="ui-field  " id="field_100" data-field-id="104" data-field-type="textInput"
                 data-validate='{&quot;required&quot;:true}' data-rule='[]' data-field-label="手机">
                <label class="field-label"> 手机 <span class="required">*</span>
                    <span id="name_err" class="tips"></span>
                </label>
                <div class="field-content">
                    <input id="phone" type="text" class="ui-input" placeholder="手机" name="phone"/>
                </div>
            </div>
            <div class="ui-field  " id="field_101" data-field-id="105" data-field-type="textInput"
                 data-validate='{&quot;required&quot;:true}' data-rule='[]' data-field-label="姓名">
                <label class="field-label"> 姓名 <span class="required">*</span>
                    <span id="name_err" class="tips"></span>
                </label>
                <div class="field-content">
                    <input id="name" type="text" class="ui-input" placeholder="姓名" name="name"/>
                </div>
            </div>
            <div class="ui-field " id="field_102" data-field-id="111" data-field-type="radio"
                 data-validate='{&quot;required&quot;:true}' data-rule='[]' data-field-label="性别">
                <label class="field-label"> 性别 <span class="required">*</span>
                    <span class="tips"></span>
                </label>
                <div class="field-content ui-list select-list">
                    <div class="list-item">
                        <div id="nan" class='radio-outside'>
                            <div class='radio-inside'></div>
                        </div>
                        <span class='option-label'>男</span>
                    </div>
                    <div class="list-item">
                        <label>
                            <input class="ui-radio" type="radio" name="111" value="2" data-label="女孩">
                        </label>
                        <div id="nv" class='radio-outside'>
                            <div class='radio-inside'></div>
                        </div>
                        <span class='option-label'>女</span>
                    </div>
                </div>
            </div>
            <div class="ui-field  " id="field_101" data-field-id="105" data-field-type="textInput"
                 data-validate='{&quot;required&quot;:true}' data-rule='[]' data-field-label="年龄">
                <label class="field-label"> 年龄 <span class="required">*</span>
                    <span id="name_err" class="tips"></span>
                </label>
                <div class="field-content">
                    <input id="age" type="text" class="ui-input" placeholder="年龄" name="age"/>
                </div>
            </div>
            <div class="ui-field  " id="field_105" data-field-id="132" data-field-type="select"
                 data-validate='{&quot;required&quot;:true}' data-rule='[]' data-field-label="角色">
                <label class="field-label"> 角色 <span class="required">*</span>
                    <span class="tips"></span>
                </label>
                <div class="field-content">
                    <select class="ui-select" name="power" id="power">
                        <option value="999">请选择</option>
                        <option value="2">作业</option>
                        <option value="3">奥数</option>
                        <option value="4">书法</option>
                        <option value="5">作文</option>
                        <option value="6">英语</option>
                    </select>
                </div>
            </div>
            <div class="ui-field  " id="field_103" data-field-id="133" data-field-type="select"
                 data-validate='{&quot;required&quot;:true}' data-rule='[]' data-field-label="教授课程">
                <label class="field-label"> 教授课程 <span class="required">*</span>
                    <span class="tips"></span>
                </label>
                <div class="field-content">
                    <select class="ui-select" name="course" id="course">
                        <option value="999">请选择</option>
                    </select>
                </div>
            </div>
            <div class="ui-field  " id="field_106" data-field-id="134" data-field-type="select"
                 data-validate='{&quot;required&quot;:true}' data-rule='[]' data-field-label="所在小区">
                <label class="field-label"> 所在小区 <span class="required">*</span>
                    <span class="tips"></span>
                </label>
                <div class="field-content">
                    <select class="ui-select" name="pos" id="pos">
                        <option value="999">请选择</option>
                        <option value="1">岗当新村</option>
                        <option value="2">东海盛景</option>
                        <option value="3">天地荣域</option>
                        <option value="4">雍雅锦江</option>
                        <option value="5">石门福地</option>
                        <option value="6">天然城</option>
                        <option value="7">红石原著</option>
                        <option value="8">天山水榭花都</option>
                        <option value="9">金色家园</option>
                        <option value="10">加洲阳光</option>
                        <option value="11">和合美家</option>
                        <option value="12">东方城</option>
                        <option value="13">天山花园</option>
                        <option value="14">想象国际</option>
                        <option value="15">小岗上新村</option>
                        <option value="16">北豆村</option>
                        <option value="17">南豆村</option>
                    </select>
                </div>
            </div>
            <div class="ui-field  center" id="field_107" data-field-id="112" data-field-type="splitLine"
                 data-validate='{&quot;required&quot;:false}' data-rule='[]' data-field-label="更多内容，建议填写">
                <div class="field-content">
                    <div class="split-line">
                        <span>更多内容，建议填写</span>
                    </div>
                </div>
            </div>
            <div class="ui-field  " id="field_108" data-field-id="124" data-field-type="textArea"
                 data-validate='{&quot;required&quot;:false}' data-rule='[]' data-field-label="特长、爱好">
                <label class="field-label">
                    特长、爱好
                    <span class="tips"></span>
                </label>
                <div class="field-content">
                        <textarea id="late_mark" name="late_mark" class="ui-textarea"
                                  placeholder="业余时间喜欢什么，都可以写上。"></textarea>
                </div>
            </div>
            <div class="ui-field " id="field_102" data-field-id="125" data-field-type="radio"
                 data-validate='{&quot;required&quot;:true}' data-rule='[]' data-field-label="婚否">
                <label class="field-label"> 婚否 <span class="required">*</span>
                    <span class="tips"></span>
                </label>
                <div class="field-content ui-list select-list">
                    <div class="list-item">
                        <div id="isnot" class='radio-outside'>
                            <div class='radio-inside'></div>
                        </div>
                        <span class='option-label'>已婚</span>
                    </div>
                    <div class="list-item">
                        <label>
                            <input class="ui-radio" type="radio" name="111" value="2" data-label="婚否">
                        </label>
                        <div id="not" class='radio-outside'>
                            <div class='radio-inside'></div>
                        </div>
                        <span class='option-label'>未婚</span>
                    </div>
                </div>
            </div>
            <button class="ui-button green" id="submit">提交</button>
        </div>
        <div id="dui-alert-tpl" type="text/template" class="hidden">
            <div class="dui-dialog-box">
                <div class="dui-mask"></div>
                <div class="dui-dialog">
                    <div class="dialog-hd">提示</div>
                    <div id="msg" class="dialog-bd"></div>
                    <div class="dialog-ft">
                        <a>确定</a>
                    </div>
                </div>
            </div>
        </div>
        <div id="loading" class="submit-loading hidden">
            <div class="wrap">
                <div class="circle"></div>
                <p>提交中</p></div>
        </div>
        <div class="submit-loading">
            <div class="wrap">
                <div class="circle"></div>
                <p>加载中</p></div>
        </div>
        <?php echo $footer; ?>
    </div>
    <div id='userinfo' class='ui-form style_9 hidden'>
        <div class="ui-title"> 文思学堂 - 数据录入平台</div>
        <div class="tips-box">
            <img src="https://wx-static.drip.im/img/shop/single/form/success.png?t=1505204250563" width='48px'
                 height='48px'/>
            <p class="tips">恭喜，提交成功！</p>
            <div>
                <a href="/" class="showData">
                    <img src="https://wx-static.drip.im/img/shop/single/form/show-data.png?t=1505204250563"/>
                    返回首页
                </a>
            </div>
            <div>
                <a href="/input" class="formBack showData">
                    <img src="https://wx-static.drip.im/img/shop/single/form/form-back.png?t=1505204250563" alt="">
                    继续填写
                </a>
            </div>
        </div>
        <footer class="drip-footer">
            <p> © <a href="/">文思学堂</a> 最终解析权 </p>
        </footer>
    </div>
</div>
</body>
<script nonce="99b4ecf93d7b2b23">
    //初始化
    $(function () {
        flogin({'t': readCooken()}, function (r) {
            console.log('r: ', r);
            r.result !== 0 ? location.href = '/' : null;
        });
        getPublic(function (r) {
            $(".submit-loading").addClass("hidden");
            if (r.result === true) {
                $.each(r.data.course, function (index, value) {
                    console.log(index, value.name);
                    $("#course").append("<option value='" + (index + 1) + "'>" + value.name + "</option>");
                });
            }
        });
    });
    //close dialogBox
    $(document).click(function () {
        $("#dui-alert-tpl").addClass("hidden");
    });
    //select change
    $(".ui-select").change(function () {
        $(this).css("color", this.value === '999' ? "" : "#333");
    });
    //元素事件
    $("#nv").click(function () {
        $("#nv").attr("class", "radio-outside radio-checked");
        $("#nan").attr("class", "radio-outside");
        $("#sex").attr("value", "2");
    });
    $("#nan").click(function () {
        $("#nan").attr("class", "radio-outside radio-checked");
        $("#nv").attr("class", "radio-outside");
        $("#sex").attr("value", "1");
    });
    $("#not").click(function () {
        $("#not").attr("class", "radio-outside radio-checked");
        $("#isnot").attr("class", "radio-outside");
        $("#marry").attr("value", "2");
    });
    $("#isnot").click(function () {
        $("#isnot").attr("class", "radio-outside radio-checked");
        $("#not").attr("class", "radio-outside");
        $("#marry").attr("value", "1");
    });
    $("button").click(function () {
        const name = $("#name").val();
        const sex = $("#sex").val();
        const marry = $("#marry").val();
        const age = $("#age").val();
        const course = $("#course").val();
        const pos = $("#pos").val();
        const phone = $("#phone").val();
        const power = $("#power").val();
        const late_mark = $("#late_mark").val();

        if (name === "") {
            $("#name").focus();
            $("#name_err").html("请填写");
            return;
        }

        //page loading
        $("#loading").removeClass("hidden");

        //request
        publicFun(
            '/manage/addTeacher',
            {
                'action': 'add',
                'name': name,
                'sex': sex,
                'age': age,
                'marry': marry,
                'course': course,
                'pos': pos,
                'phone': phone,
                'power': power,
                'late_mark': late_mark
            }, function (r) {
                if (!r.result === 0) {
                    $("#form").addClass("hidden");
                    $("#userinfo").removeClass("hidden");
                } else {
                    $("#dui-alert-tpl").removeClass("hidden");
                    $("#msg").html(r.msg);
                }
                $("#loading").addClass("hidden");
            });
    });
</script>
</html>